1 ========================================================================
2 CONSOLE APPLICATION : CSSocketServer Project Overview
3 ========================================================================
5 /////////////////////////////////////////////////////////////////////////////
8 Sockets are an application programming interface (API) in an operating system,
9 used for in inter-process communication. Sockets constitute a mechanism for
10 delivering incoming data packets to the appropriate application process or
11 thread, based on a combination of local and remote IP addresses and port
12 numbers. Each socket is mapped by the operational system to a communicating
13 application process or thread.
16 .NET supplies a Socket class which implements the Berkeley sockets interface.
17 It provides a rich set of methods and properties for network communications.
18 The Socket class allows you to perform both synchronous and asynchronous data
19 transfer using any of the communication protocols listed in the ProtocolType
20 enumeration. It supplies the following types of socket:
22 Stream: Supports reliable, two-way, connection-based byte streams without
23 the duplication of data and without preservation of boundaries.
25 Dgram:Supports datagrams, which are connectionless, unreliable messages of
26 a fixed (typically small) maximum length.
28 Raw: Supports access to the underlying transport protocol.Using the
29 SocketTypeRaw, you can communicate using protocols like Internet Control
30 Message Protocol (Icmp) and Internet Group Management Protocol (Igmp).
32 Rdm: Supports connectionless, message-oriented, reliably delivered messages,
33 and preserves message boundaries in data.
35 Seqpacket:Provides connection-oriented and reliable two-way transfer of
36 ordered byte streams across a network.
38 Unknown:Specifies an unknown Socket type.
40 There are some limitations on this sample:
42 1. Due to the socket buffer size, the string message including EOM marker shouldn't
43 bigger than 1024 bytes when encoded to bytes by Unicode.
45 2. The sample is designed for receiving and sending only one string message.
47 To overcome the limitations above, the developer need handle message separating
48 and merging operations on socket buffer.
51 /////////////////////////////////////////////////////////////////////////////
54 CSSocketClient <--> CSSocketServer
55 CSSocketClient is the client process to communicate the server process
59 /////////////////////////////////////////////////////////////////////////////
62 1. Create a socket to listen the incoming TCP connection.
64 2. After get the client connection,asynchronously receive the data and listen
65 the TCP connection again.
67 3. Finishing receiving data, send the response to client process.
69 4. If user inputs the word quit to exit the program
72 /////////////////////////////////////////////////////////////////////////////
75 Chapter4: Using Sockets of Professional .NET Network Prgromming
76 http://www.amazon.com/Professional-Network-Programming-Srinivasa-Sivakumar/dp/1861007353
79 http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx
81 Asynchronous Server Socket Example
82 http://msdn.microsoft.com/en-us/library/fx6588te.aspx
85 /////////////////////////////////////////////////////////////////////////////